local cetu = fk.CreateSkill{
  name = "xiaobai__cetu"
}

Fk:loadTranslationTable{
  ["xiaobai__cetu"] = "策图",
  [":xiaobai__cetu"] = "你可以跳过额定回合，改为询问一名其他角色是否使用一张牌。若是，你可以摸两张牌并再次询问。若还是，你可以使用一张牌并再次"..
  "询问。",

  ["#xiaobai__cetu1-choose"] = "策图：是否跳过额定回合，询问一名其他角色是否使用一张牌？",
  ["#xiaobai__cetu-ask"] = "策图：你可以使用一张牌",
  ["#xiaobai__cetu-draw"] = "策图：是否摸两张牌并继续询问？",
  ["#xiaobai__cetu-choose"] = "策图：询问一名其他角色是否使用一张牌",
  ["#xiaobai__cetu-use"] = "策图：是否使用一张牌并继续询问？",

  ["$xiaobai__cetu1"] = "淮海非坦途，岂敢寄命洪流，以徼乾没？",
  ["$xiaobai__cetu2"] = "屈人之兵非战，拔人之城非攻，此庙胜必然之理。",
}

cetu:addEffect(fk.BeforeTurnStart,{
  name = "xiaobai__cetu",
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and not player:insideExtraTurn() and #player.room.alive_players > 0
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local to = room:askToChoosePlayers(player, {
      targets = room:getOtherPlayers(player),
      min_num = 1,
      max_num = 1,
      prompt = "#xiaobai__cetu1-choose",
      skill_name = cetu.name})
    if #to > 0 then
      event:setCostData(self, {tos = to})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).tos[1]
    if room:askToPlayCard(to, {
      room = room, 
      skill_name = cetu.name,
      prompt = "#xiaobai__cetu-ask", 
      extraUse = true,
      bypass_times = true}) then
      if player.dead or #room.alive_players < 2 then return end
      if room:askToSkillInvoke(player, {skill_name = cetu.name, prompt = "#xiaobai__cetu-draw"}) then
        player:drawCards(2, cetu.name)
        if player.dead or #room.alive_players < 2 then return end
        to = room:askToChoosePlayers(player, {
          targets = room:getOtherPlayers(player),
          min_num = 1,
          max_num = 1,
          prompt = "#xiaobai__cetu-choose",
          skill_name = cetu.name,
          cancelable = true})[1]
        if room:askToPlayCard(to, {
          room = room, 
          skill_name = cetu.name,
          prompt = "#xiaobai__cetu-ask", 
          extraUse = true,
          bypass_times = true}) then
          if player.dead then return end
          if room:askToPlayCard(player, {
            room = room, 
            skill_name = cetu.name,
            prompt = "#xiaobai__cetu-ask", 
            extraUse = true,
            bypass_times = true}) then
            if player.dead or #room.alive_players < 2 then return end
            to = room:askToChoosePlayers(player, {
              targets = room:getOtherPlayers(player), 
              min_num = 1, 
              max_num = 1,
              prompt = "#xiaobai__cetu-choose", 
              skill_name = cetu.name,
              cancelable = false})[1]
            room:askToPlayCard(to, {
              room = room, 
              skill_name = cetu.name,
              prompt = "#xiaobai__cetu-ask", 
              extraUse = true,
              bypass_times = true})
          end
        end
      end
    end
  end,
})

cetu:addEffect(fk.TurnStart, {
  can_refresh = function (self, event, target, player, data)
    return player:usedSkillTimes(cetu.name, Player.HistoryTurn) > 0
  end,
  on_refresh = function (self, event, target, player, data)
    player.room.logic:getCurrentEvent():shutdown()
  end,
})


return cetu
